package org.lazycoder.logger;

import java.io.File;
import java.util.Date;
import java.util.Iterator;
import java.util.Vector;

/**
 * EventLogger class to insert into the database.
 * 
 * @author Matthew Bayliss
 * 
 */
public class Event implements Iterable<File> {
	private final String Message;
	private final Date Timestamp;
	private final Vector<File> files = new Vector<File>();

	/**
	 * Create an event with the message msg.
	 * 
	 * @param msg
	 *            A message to send with the event (what has happened?)
	 */
	public Event(String msg, Date ts) {
		Message = msg;
		Timestamp = ts;
	}

	/**
	 * Create an event with the message message. This will auto generate a
	 * timestamp, this will create some latency.
	 * 
	 * @deprecated latency is not forensically awesome.
	 * @param msg
	 *            A message for the event.
	 */
	public Event(String msg) {
		Message = msg;
		Timestamp = new Date();
	}

	/**
	 * Add a message to go with the file. This was implemented to allow images
	 * to be sent with events, but should work for anything as my planned
	 * implementation is to send blobs.
	 * 
	 * @param file
	 *            the file to send
	 */
	public void addFile(File file) {
		files.add(file);
	}

	/**
	 * Get the message from this event (this is the message from the constructor
	 * as there is no other way to set it)
	 * 
	 * @return The event description
	 */
	public String getMessage() {
		return Message;
	}

	/**
	 * 
	 * @return Grab the timestamp for this event
	 */
	public Date getTimestamp() {
		return Timestamp;
	}

	@Override
	public Iterator<File> iterator() {
		return files.iterator();
	}
}
